﻿package mortal.game.net.command.fashion
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import extend.language.*;
    import flash.utils.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.mvc.core.*;

    public class FashionCommand extends BroadCastCall
    {

        public function FashionCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_2:SPublicFashion = null;
            var _loc_3:SSeqAttributeUpdate = null;
            Log.debug("I have receive FashionCommand");
            super.call(param1);
            switch(param1.messageHead.command)
            {
                case EGateCommand._ECmdGateFashion:
                {
                    _loc_2 = param1.messageBase as SPublicFashion;
                    Cache.instance.fashion.saveFashionServerInfo(_loc_2);
                    Cache.instance.fashion.updateFashionExpiredTime(_loc_2);
                    Cache.instance.fashion.updateAdvanceReturnInfo(_loc_2);
                    Cache.instance.fashion.updateFashionHideStateInfo(_loc_2);
                    Cache.instance.fashion.updateFashionShapState(_loc_2);
                    break;
                }
                case EGateCommand._ECmdGateFashionUpdate:
                {
                    _loc_3 = param1.messageBase as SSeqAttributeUpdate;
                    this.onFashionInfoUpdate(_loc_3);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function onFashionInfoUpdate(param1:SSeqAttributeUpdate) : void
        {
            var _loc_2:SAttributeUpdate = null;
            var _loc_3:Dictionary = null;
            var _loc_4:SPublicFashion = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:Date = null;
            var _loc_8:Date = null;
            for each (_loc_2 in param1.updates)
            {
                
                _loc_3 = Cache.instance.fashion.serverFashionInfoDic;
                _loc_4 = _loc_3[int(_loc_2.valueStr)] as SPublicFashion;
                if (_loc_4)
                {
                    switch(_loc_2.attribute.value())
                    {
                        case EEntityAttribute._EAttributeFashionBless:
                        {
                            _loc_5 = _loc_2.value - _loc_4.bless;
                            _loc_6 = _loc_4.bless;
                            _loc_4.bless = _loc_2.value;
                            if (_loc_5 > 0)
                            {
                                MsgManager.showMouseMsg(Language.getStringByParam(20501, _loc_5), MsgRollTipsType.msgRollTips2);
                                if (_loc_6 == 0)
                                {
                                    _loc_7 = ClockManager.instance.nowDate;
                                    _loc_8 = new Date(_loc_7.time);
                                    (_loc_8.date + 1);
                                    _loc_4.lastAdvanceSuccessDt = _loc_8;
                                    Cache.instance.fashion.updateFashionExpiredTime(_loc_4);
                                    NetDispatcher.dispatchCmd(ServerCommand.FashionUpdateExpiredTime, null);
                                }
                            }
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionAdvancedNum:
                        {
                            _loc_4.advanceNum = _loc_2.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionCode:
                        {
                            _loc_4.code = _loc_2.value;
                            Cache.instance.fashion.updateConfigInfo(int(_loc_2.valueStr));
                            NetDispatcher.dispatchCmd(ServerCommand.FashionLevelUp, int(_loc_2.valueStr));
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionShape:
                        {
                            _loc_4.shapeCode = _loc_2.value;
                            NetDispatcher.dispatchCmd(ServerCommand.FashionShapeChange, _loc_2.value);
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionCurrentTalentNum:
                        {
                            _loc_4.currentTalentNum = _loc_2.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionTotalTalentNum:
                        {
                            _loc_4.totalTalentNum = _loc_2.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionCurrentGrowthNum:
                        {
                            _loc_4.currentGrowthNum = _loc_2.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionTotalGrowthNum:
                        {
                            _loc_4.totalGrowthNum = _loc_2.value;
                            break;
                        }
                        case EEntityAttribute._EAtrributeFashionReturn:
                        {
                            _loc_4.advanceReturn = _loc_2.value;
                            Cache.instance.fashion.updateAdvanceReturnInfo(_loc_4);
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionStatus:
                        {
                            _loc_4.state = _loc_2.value;
                            Cache.instance.fashion.updateFashionHideStateInfo(_loc_4);
                            NetDispatcher.dispatchCmd(ServerCommand.FashionActiveFashion, _loc_2);
                            break;
                        }
                        case EEntityAttribute._EAttributeFashionShapeCardStatus:
                        {
                            _loc_4.shapeCardStatus = _loc_2.value;
                            Cache.instance.fashion.updateFashionShapState(_loc_4);
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                    Cache.instance.fashion.updateServerInfo(int(_loc_2.valueStr), _loc_4);
                }
                NetDispatcher.dispatchCmd(ServerCommand.FashionInfoUpdate, _loc_2);
            }
            return;
        }// end function

    }
}
